package easy;

public class Solution_717 {

    public boolean isOneBitCharacter(int[] bits) {
        boolean[] flags = new boolean[bits.length];
        for (int i = 0; i < bits.length; i++) {
            if (bits[i] == 0) {
                flags[i] = true;
            } else {
                if (i > 0 && !flags[i - 1]) {
                    flags[i] = true;
                } else {
                    flags[i] = false;
                }
            }
        }
        return flags.length==1 || flags[flags.length - 2];
    }

    public static void main(String[] args) {
        Solution_717 model = new Solution_717();
        System.out.println(model.isOneBitCharacter(new int[]{1, 0, 0}));
        System.out.println(model.isOneBitCharacter(new int[]{1, 1, 1, 0}));
    }
}
